home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / mpss / orbit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-20  |  6.6 KB  |  222 lines

  1.  
  2. /*******************************************************************************
  3. ********************************************************************************
  4. ********************************************************************************
  5.  
  6. PERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT
  7. THIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES.
  8.  
  9.         P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988.
  10.  
  11.  
  12. ********************************************************************************
  13. ********************************************************************************
  14. *******************************************************************************/
  15. #include "header.h"
  16. #include "planets.h"
  17.  
  18.  
  19. updateship(cp)
  20. register struct player *cp;
  21. {
  22. switch (cp->planetno)
  23. {
  24. case 1: cp->phaserreach += 2; plotphaserbanks(cp);
  25. break;
  26. case 3: cp->energy += 50; cp->maxenergy += 50; plotbattleenergy(cp);
  27. break;
  28. case 4: cp->maxphoton +=3; plotphotontorpedos(cp); 
  29. break;
  30. case 5: cp->maxvel +=1;
  31. break;
  32. case 6: cp->phaserpower +=20;
  33. break;
  34. case 7: cp->phaserbanks=0; cp->photontorpedos=0; 
  35.     plotphotontorpedos(cp); plotphaserbanks(cp);
  36. break;
  37. case 8: cp->maxphaser+=10; plotphaserbanks(cp);
  38. break;
  39. case 9: cp->photonreach +=3; cp->phaserbanks=cp->maxphaser; cp->photontorpedos=cp->maxphoton;
  40.     plotphotontorpedos(cp); plotphaserbanks(cp);
  41. break;
  42. case 10: cp->score += 150; cp->maxenergy+=200; plotmaxenergy(cp);
  43.     plotscore(cp);
  44. break;
  45. case 11: cp->photonpower+=300; 
  46. break;
  47. case 12: cp->phaserpower +=80;
  48. break;
  49. case 14: cp->maxvel +=1;
  50. break;
  51. case 15: cp->phaserreach +=2; plotphaserbanks(cp);
  52. break;
  53. case 16: cp->score+=200; plotscore(cp);
  54. break;
  55. case 17: cp->phaserpower+=100; plotphaserbanks(cp);
  56. break;
  57. case 19: cp->score +=50; plotscore(cp);
  58. break;
  59. case 20: cp->maxphoton+=7; cp->maxphaser+=3;
  60.     plotphotontorpedos(cp); plotphaserbanks(cp);
  61. break;
  62. case 21:cp->score=0; plotscore(cp);
  63. break;
  64. case 22: cp->score +=50; plotscore(cp);
  65. break;
  66. case 23: cp->photonreach +=1; plotphotontorpedos(cp);
  67. break;
  68. case 24: cp->maxvel+=1;
  69. break;
  70. case 28: cp->score+=cp->score; plotscore(cp);
  71.      cp->maxphoton+=20; cp->maxphaser+=30;
  72.      cp->photontorpedos+=20; cp->phaserbanks+=30;
  73.      cp->photonreach+=5; cp->phaserreach+=5;
  74.      cp->maxenergy+=300; 
  75.      plotbattleenergy(cp);
  76.      plotphotontorpedos(cp); plotphaserbanks(cp);
  77. break;
  78. default:
  79. break;
  80. } /*switch*/
  81. }
  82.  
  83. noofplanet(x,y)
  84. {
  85. i=0;
  86. while (!((plan[i].xpos==x)&&(plan[i].ypos==y))) i++;
  87. return(i);
  88. }
  89.  
  90. orbit(cp)
  91. register struct player *cp;
  92. {
  93. int decay,orbitingok;
  94.  
  95. decay=OFF;
  96. orbitingok=OFF;
  97. i=cp->xpos;
  98. j=cp->ypos;
  99.  
  100. if (((cp->xvel==0) && (cp->yvel==0))&&
  101.     ((inuniv(i+1,j-1)=='O')||
  102.     (inuniv(i+1,j)=='O')||
  103.     (inuniv(i+1,j+1)=='O')||
  104.     (inuniv(i-1,j-1)=='O')||
  105.     (inuniv(i-1,j)=='O')||
  106.     (inuniv(i-1,j+1)=='O')||
  107.     (inuniv(i,j+1)=='O')||
  108.     (inuniv(i,j-1)=='O')))
  109.         decay=ON;
  110. if (decay)
  111.     {
  112.     plot1(cp,"Spock : We attempted orbit too close to the planet sir.  ");
  113.     plot2(cp,"Most of our energy has been used to keep us in the air.  ");
  114.     cp->energy -= 300;
  115.     cp->maxenergy -= 300;
  116.     plotenergy(cp);
  117.     plotmaxenergy(cp);
  118.     return(0);
  119.     } 
  120.  
  121. if ((cp->xvel==0) && (cp->yvel==0))
  122. {
  123. if(inuniv(i-2,j+2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-2,j+2);goto label2;}
  124. if(inuniv(i-2,j+1)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-2,j+1);goto label2;}
  125. if(inuniv(i-2,j)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-2,j);goto label2;}
  126. if(inuniv(i-2,j-1)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-2,j-1);goto label2;}
  127. if(inuniv(i-2,j-2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-2,j-2);goto label2;}
  128. if(inuniv(i+2,j+2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+2,j+2);goto label2;}
  129. if(inuniv(i+2,j+1)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+2,j+1);goto label2;}
  130. if(inuniv(i+2,j)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+2,j);goto label2;}
  131. if(inuniv(i+2,j-1)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+2,j-1);goto label2;}
  132. if(inuniv(i+2,j-2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+2,j-2);goto label2;}
  133. if(inuniv(i+1,j-2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+1,j-2);goto label2;}
  134. if(inuniv(i,j-2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i,j-2);goto label2;}
  135. if(inuniv(i-1,j-2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-1,j-2);goto label2;}
  136. if(inuniv(i+1,j+2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i+1,j+2);goto label2;}
  137. if(inuniv(i,j+2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i,j+2);goto label2;}
  138. if(inuniv(i-1,j+2)=='O'){orbitingok=ON;cp->planetno=noofplanet(i-1,j+2);goto label2;}
  139. }
  140. label2:
  141. if (orbitingok==OFF)
  142.     {
  143.     plot1(cp,"   Spock : Fascinating. I've never attempted to orbit    ");
  144.     plot2(cp,"              a non-existent planet.                     ");
  145.     } else
  146.     {
  147.     if ((cp->cloakingdevice)||(cp->shields))
  148.         {
  149.         if (cp->shields)
  150.         {
  151.     plot1(cp,"                                                         ");
  152.     plot2(cp," Orbit while you have your shields are up? Youre kidding!");
  153.         }
  154.         else
  155.         {
  156.     plot1(cp,"                                                         ");
  157.     plot2(cp,"    Orbit while you are cloaked? You are optimistic!     ");
  158.         } 
  159.     } else
  160.         {
  161.     plot1(cp,"        Sulu : We are now in standard orbit Captain.     ");
  162.     plot2(cp,plan[cp->planetno].orbit);
  163.         plotstatus(cp,8);
  164.         }
  165.     }
  166. }
  167.  
  168. unorbit(cp)
  169. register struct player *cp;
  170. {
  171. if ((cp->stat==8) && (cp->xvel==0) && (cp->yvel==0)) 
  172. {
  173. plot1(cp," Saavik : Aft impulse thrusters 1/2 impulse power ahead. ");
  174. plot2(cp,"         Sulu : Orbit termination completed Captain.     ");
  175. plotstatus(cp,3);
  176. } else
  177. {
  178. plot1(cp,"Chekov : We are not in orbit at the moment!Bones : I best");
  179. plot2(cp," take you to sick bay and have your brains checked  Jim. ");
  180. }
  181. }
  182.  
  183. noland(cp)
  184. register struct player *cp;
  185. {
  186. plot1(cp,"     A protective shield around this planet makes it     ");
  187. plot2(cp,"     impossible to beam down sir.This might change.      ");
  188. }
  189.  
  190. beamdown(cp)
  191. register struct player *cp;
  192. {
  193. if (cp->planets[cp->planetno]>0)
  194.     {
  195.     plot1(cp,"   We have been to this planet already. You cannot       ");
  196.     plot2(cp,"                beam down twice.                         ");
  197.     return(0);
  198.     }
  199. j=cp->planetno;
  200. switch (j)
  201. {
  202. case 2  : if (cp->planets[17]==0) {noland(cp); return(0); } else break;
  203. case 15 : if (cp->planets[14]==0) {noland(cp); return(0); } else break;
  204. case 19 : if (cp->planets[18]==0) {noland(cp); return(0); } else break;
  205. case 26 : if (cp->planets[25]==0) {noland(cp); return(0); } else break;
  206. case 27 : if (cp->planets[26]==0) {noland(cp); return(0); } else break;
  207. case 28 : if (cp->planets[27]==0) {noland(cp); return(0); } else break;
  208. default :
  209.     break;
  210. }
  211. plot1(cp,"   Energizing.......................................     ");
  212. plot2(cp,"                                                         ");
  213. cp->oldstat=cp->stat;
  214. plotstatus(cp,10);
  215. cp->planets[j]=1;
  216. for (i=1;i<20;++i)
  217.     {
  218.     poscurs(cp,20,i);
  219.     write(cp->fd,plan[j].land[i-1],57);
  220.     }
  221. }
  222.